<?
 $facility_id=(isset($selected_facility_id)?$selected_facility_id:0);
 
?> 
<script type="text/javascript">
jQuery(function($) {
	$("#btn_go_back").click(function(){
	   window.location.replace("/admin/facility");
	});
	
	$("#btn_delete_facility").click(function(){
		var res=confirm("Are you sure you want to delete this facility?"); 
		if(res==true){
			window.location.replace("/admin/facility/delete/<?=$facility_id?>");
		} 
	});
	
	if(jQuery("#nortify").css('display')!= 'none'){
        jQuery("#nortify").fadeOut(4000);
	}
	  
});
  
</script>
<section id="content">
	<section class="container_12 clearfix">
		<section id="main" class="grid_12">
			<article class="content">
				<h1>Add Hotel Facility</h1>  
                <?= validation_errors('<div id="info_msg" style="display:block;"  class="error msg">','</div>') ?>
				<?
					if(isset($message_id)){
						switch($message_id){
							case 'i':{
								echo '<div id="nortify" style="display:block;" class="success msg">The facility has been added successfully.</div>';
							}break;
							case 'u':{
								echo '<div id="nortify" style="display:block;" class="success msg">The facility has been updated successfully.</div>';
							}break;
						}
					} 
                 
				 	$attributes = array('name' => 'facility_save', 'id' => 'facility_save');
				echo form_open_multipart('admin/facility/save', $attributes); 
				?>
				<?=form_hidden('facility_id',$facility_id);?>
					<ul class="tabs">
						<li><a href="#general">Facility Edit</a></li> 
					</ul>
					<div class="tabcontent">
						<div id="general">
							<dl class="inline">
<?
$data = array(
	'name'=>'name',
	'id'=>'name',
	'value'=>(isset($facility_data)?$facility_data[0]->name:''),
	'maxlength'=>'100',
	'size'=>'50',
	'class'=>'medium'
);
?>
								<dt>
								  <label for="site_facility">Facility</label></dt>
								<dd><?=form_input($data)?></dd>
<?
$data = array(
  'name'        => 'description',
  'id'          => 'description',
  'value'       => (isset($facility_data)?$facility_data[0]->description:''), 
  'size'        => '40',
  'style'       => 'width:100%',
);		
?>
                                <dt><label for="site_description">Description</label></dt>
								<dd><?=form_textarea($data)?></dd>
<?
$data = array(
	'name'=>'icon',
	'id'=>'icon',
	'value'=>(isset($facility_data)?$facility_data[0]->icon:''),
	'maxlength'=>'100',
	'size'=>'50',
	'class'=>'medium'
);
?>
								<dt><label for="site_logo">Logo</label></dt>
								<dd>
									<input type="file" id="facility_logo" name="facility_logo" />
									<small>Facility icon (jpg, gif, png)</small>
                                    <small><img src="/images/hotel-facility/<?=(isset($facility_data)?($facility_data[0]->icon!=''?$facility_data[0]->icon:'preview-file.png'):'preview-file.png')?>" width="32" height="32" border="0"></small>
								</dd>                               
<?
$data = array(
	'name'        => 'is_enabled',
	'id'          => 'is_enabled',
	'value'       => '1',
	'checked'     => (isset($facility_data)?$facility_data[0]->is_enabled:false),
	'style'       => 'margin:10px',
);
?>
                                <dt><label for="site_description">Is Enabled</label></dt>
								<dd><?=form_checkbox($data);?></dd>                                
							</dl>
						</div> 
					</div>
					<div class="buttons">
                    	<button id="btn_go_back" type="button" class="button">Go Back</button>
						<button type="submit" class="button">Save Settings</button>
						<button id="btn_delete_facility" type="button" class="button white">Delete Facility</button>
					</div>
				<!--</form>-->
                <?=form_close()?>
			</article>
		</section>
	</section>
</section>

<footer id="bottom">
	<section class="container_12 clearfix">
		<div class="grid_6">
			<a href="#">Menu 1</a>
			&middot; <a href="#">Menu 2</a>
			&middot; <a href="#">Menu 3</a>
			&middot; <a href="#">Menu 4</a>
		</div>
		<div class="grid_6 alignright">
			Copyright &copy; 2011 <a href="#">YourCompany.com</a>
		</div>
	</section>
</footer>
 